<?php
// +----------------------------------------------------------------------
// | KITEGO-Admin「开箱即用」「人人全栈」
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2024 https://www.kitego.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed KITEGO并不是自由软件，未经许可不能去掉KITEGO相关版权
// +----------------------------------------------------------------------
// | Author: KITEGO Team <bd@kitego.cn>
// +----------------------------------------------------------------------

namespace app\adminapi\validate\setting;

use kitego\enum\AttachmentCategoryEnum;
use kitego\enum\AttachmentEnum;
use think\Validate;

class AttachmentValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名' =>  ['规则1','规则2'...]
     *
     * @var array
     */
    protected $rule = [
        'id|主键id' => 'require|number',
        'pid|父级id' => 'require|number',
        'name|分类名称' => 'require',
        'type|分类类型' => ['require', 'in' => [AttachmentCategoryEnum::IMAGE, AttachmentCategoryEnum::VIDEO, AttachmentCategoryEnum::FILE]],
        'source|来源' => ['in' => [AttachmentEnum::FILE_UPLOAD_SOURCE_ADMIN, AttachmentEnum::FILE_UPLOAD_SOURCE_USER]],
        'cid|分类id' => 'number',
        'ids|附件数组' => 'array',
        'uploadType|附件上传类型' => ['require', 'in' => AttachmentEnum::FILE_UPLOAD_TYPE],
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名' =>  '错误信息'
     *
     * @var array
     */
    protected $message = [
    ];

    /**
     * 验证场景定义
     * @var array
     */
    protected $scene = [
        'attachmentCategoryAdd' => ['pid', 'name', 'type'],
        'attachmentCategoryRename' => ['id', 'name'],
        'attachmentCategoryDelete' => ['id'],
        'attachmentList' => ['type'],
        'attachmentRename' => ['id', 'name', 'type'],
        'attachmentMove' => ['cid', 'ids'],
        'attachmentDelete' => ['ids'],
        'attachmentUpload' => ['uploadType', 'cid']
    ];
}
